import { Entity, Column, PrimaryGeneratedColumn, UpdateDateColumn} from 'typeorm';
import { ApiProperty} from '@nestjs/swagger';
import { MaxLength, IsOptional } from 'class-validator';
import { CrudValidationGroups } from '@nestjsx/crud';

const { CREATE, UPDATE } = CrudValidationGroups;

@Entity()
export class Topic {
  @PrimaryGeneratedColumn()
  id: number;

  @IsOptional({groups:[CREATE,UPDATE]})
  @ApiProperty()
  @Column({type: 'varchar', length: 255})
  title: string;

  @IsOptional()
  @ApiProperty()
  @Column({type: 'text'})
  content: string;

  @IsOptional()
  @ApiProperty()
  @Column({type: 'varchar', length: 255})
  avatar: string;

  @IsOptional()
  @ApiProperty()
  @Column({type: 'varchar', length: 255})
  item_pic_url: string;

  @IsOptional()
  @ApiProperty()
  @Column({type: 'varchar', length: 255})
  subtitle: string;

  @IsOptional()
  @ApiProperty()
  @Column({type: 'int'})
  topic_category_id: number;

  @IsOptional()
  @ApiProperty()
  @Column({type: 'decimal', width: 10, comment:"活动价格", default:0.00})
  price_info: number;

  @IsOptional()
  @ApiProperty()
  @Column({type: 'varchar', length: 255})
  read_count: string;

  @IsOptional()
  @ApiProperty()
  @Column({type: 'varchar', length: 255, comment:"场景图片链接"})
  scene_pic_url: string;

  @IsOptional()
  @ApiProperty()
  @Column({type: 'int', comment: "活动模板Id" })
  topic_template_id: number;

  @IsOptional()
  @ApiProperty()
  @Column({type: 'int', comment: "活动标签Id" })
  topic_tag_id: number;
  
}
